using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Server
{
    public partial class ServerConfig : Form
    {
        private String _password;
        private UInt16 _port;
        private char _pauseKey;
        public ServerConfig()
        {
            InitializeComponent();
        }
        /// <summary>
        /// get the password specified by the user
        /// </summary>
        public String Password {
            get { return _password; }
        }
        /// <summary>
        /// get the port number specified by the user
        /// </summary>
        public UInt16 Port{
            get { return _port; }
        }

        public char PauseKey
        {
            get { return _pauseKey; }
        }

        private void okButtonClicked(object sender, EventArgs e)
        {
            String porta = portTextBox.Text;
            try
            {
                _port = UInt16.Parse(porta);
                _password = passwordTextBox.Text;
                if(_password.Equals("") || !_password.Equals(passwordRipTextBox.Text))
                {
                    MessageBox.Show("Password error","Error");
                }
                else
                {
                    if (pauseKey.Text.Equals(""))
                        MessageBox.Show("Pause value error","Error");
                    else
                    {
                        _pauseKey = pauseKey.Text.ToCharArray()[0];
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Port value error","Error");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }
    }
}